package com.ruoyi.house.domain;

import lombok.Data;

/**
 * 作用是用于前后端交互的，给后端提供数据 或者失败的原因等等
 */
@Data
public class Result<T> {

    private Integer code=200;// 200 代表成功
    private String errInfo = "";
    private Object jdata;// 如果数据正确的，返回给前端的数据

    private static  Result  OK = new Result(200,"","");

    public Result(Integer code, String errInfo, Object jdata) {
        this.code = code;
        this.errInfo = errInfo;
        this.jdata = jdata;
    }

    public static Result OK(){
            return  OK;
    }

    public static Result OK(Object jdata){
        return  new Result(200,"",jdata);
    }

    public static Result failed(int code){
        return  new Result(code,"",code);
    }

    public static Result failed(int code,String errInfo){
        return  new Result(code,errInfo,null);
    }


    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", errInfo='" + errInfo + '\'' +
                ", jdata=" + jdata +
                '}';
    }
}
